Repository navigation
fix(physical-backup): Remove backup metadata when the backup fails (backport #662) - #663
Merged
Merged
Conversation
The physical backup writes physical_backup_meta.json into each database directory so that the snapshot carries it. The job removed the file only after every step passed. When a step failed, for example when the snapshot request to press returned an error, the file stayed behind. MariaDB does not know this file, so a later DROP DATABASE could not remove the directory and failed with errno 39 "Directory not empty". Site restores then failed at the Restore Site step on every retry. Remove the metadata in a finally block, so that it goes after a failed backup too. Also suppress errors per database, so that one missing file does not stop the cleanup of the other databases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 17d51c5)
Contributor
Author
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A physical backup writes
physical_backup_meta.jsoninto the data directory of each database (/var/lib/mysql/<db>/), so that the disk snapshot carries it.create_backup_jobremoved this file only at the end, after every step passed.When a step failed, the file stayed. One example is
Create Database Snapshot, when the snapshot request to press returns an HTTP error that the job does not retry. MariaDB does not know this file. So a laterDROP DATABASEdeletes the table files, but cannot remove the directory:Each site restore then fails at the
Restore Sitestep, every time, until someone removes the file by hand on the database server.Fix
finallyblock, so that a failed backup also removes it.remove_backups_metadata, suppress errors for each database separately. Before, one missing file ended the loop, and the files of the other databases stayed.Tests
agent/tests/test_database_physical_backup.pychecks that the metadata goes after a successful backup, after a failed snapshot, and for every database when one file is already missing.🤖 Generated with Claude Code
This is an automatic backport of pull request #662 done by Mergify.